Conventionally, detection of a moving object in a moving image using a background image has been practiced. Typically, in this case, difference images are derived from frames that are contained in the moving image and a background image, and a region appearing in binarized images of these difference images is detected as a region including the moving object.
There are cases where a plurality of background values (pixel values representing the background) are set for each pixel in such a background image so that, for example, in the case where plants in the background sway in the wind, and a state in which a certain pixel represents the plants and a state in which that pixel represents the sky are repeated, both of these states can be recognized as the background. Also, in the case where some object appears in a screen, and that object does not move for at least a certain period of time, after a certain point in time, it may become appropriate to consider the object to be the background, rather than considering it to be a moving object serving as a search target.
In order to set a plurality of background values as described above, a mixed distribution model that is obtained by combining a plurality of distributions can be used (see Patent Literatures 1 (JP 2011-123742A) and Patent Literature 2 (JP 2013-65151A)). Taking the above-described swaying of plants as an example, one of these distributions indicates a probability distribution of the pixel value (first background value) representing the plants, and another indicates a probability distribution of the pixel value (second background value) representing the sky.
Conventionally, such a mixed distribution model is statistically generated for each pixel based on data on a large number of pixel values of that pixel that are obtained along a time axis. In this regard, according to Patent Literature 1, no mixed distribution model for determining the background values is generated until a certain preparation time has elapsed and a sufficient number of pixel values have been obtained for a single pixel. On the other hand, according to Patent Literature 2, in an initial stage at which a first pixel value has been obtained, a distribution is generated from only data on that single pixel value. Specifically, the single pixel value is used as the initial value of the mean of the distribution, and a predetermined initial value is used as the range (variance etc.) of the distribution around that mean value. Also, according to Patent Literature 2, during update of a mixed distribution model, when a pixel value that cannot be classified into any existing distribution is obtained, a distribution into which that single pixel value is classified is generated in a like manner. It should be noted that such an outlier may occur when another background appears, for example.
If a mixed distribution model is generated according to a method such as those described above, the moving object cannot be detected in the initial stage (in the case of Patent Literature 1), or the detection accuracy is unstable (in the case of Patent Literature 2). That is to say, as disclosed in Patent Literature 2, if an initial mixed distribution model is generated from only the data on the first pixel value without using data on a large number of actual pixel values, it is unlikely that the generated model appropriately models the actual scene, and erroneous detection tends to occur for a while afterwards. Similarly, if an outlier occurs during update of the mixed distribution model, erroneous detection tends to occur for a while afterwards.
It is an object of the present invention to provide an image processing apparatus, a computer-readable medium storing an image processing program, and an image processing method that can set an appropriate background value in an initial stage and/or during update of a background image and detect a moving object with high accuracy.